import 'package:cached_network_image/cached_network_image.dart';
import 'package:find_friend/pages/login&register/model/shared_user_info.dart';
import 'package:find_friend/pages/mine/mine_photos_wall.dart';
import 'package:find_friend/pages/xspace/model/school_model.dart';
import 'package:flutter/material.dart';
import 'package:find_friend/const/const.dart';


class XDiscussImagesWidget extends StatelessWidget {

  final List<Photo> list;
  final double height;
  final String heroPerfix;

  const XDiscussImagesWidget({Key key, this.list, this.height, this.heroPerfix = "heroPerfix"}) : super(key: key);

  @override
  Widget build(BuildContext context) {

    final size = MediaQuery.of(context).size;
    final width = size.width * 0.5 / 2.0;

    return Container(
      width: width * 2.5,
      child: Wrap(
              spacing: 2.5,
              runSpacing: 2.5,
              alignment: WrapAlignment.start,
              children: list.map((e) => 
                GestureDetector(
                  onTap: (){
                    List<FileModel> temp = list.map((e) => FileModel(url: e.url, id: 0, audiourl: e.ownerUrl, duration: e.playtime)).toList();
                    Navigator.push(context, PageRouteBuilder(
                      pageBuilder: (BuildContext context, Animation animation,
                          Animation secondaryAnimation) {
                        return new FadeTransition(
                          opacity: animation,
                          child: MinePhotoWallPage(list: temp,heroTag: heroPerfix + e.url + list.indexOf(e).toString()),
                        );
                      })
                    ); 
                  },
                  child: PhysicalModel(
                        color: Colors.white,
                        borderRadius: BorderRadius.circular(5),
                        clipBehavior: Clip.antiAlias,
                        child: Hero(
                          tag: heroPerfix + e.url + list.indexOf(e).toString(),
                          // child: Image.network(e.url, width: width, height: height != null ? height.h : 60.h,fit: BoxFit.fitWidth,)
                          child: CachedNetworkImage(
                            imageUrl: e.url, width: width, height: height != null ? height.h : 60.h,fit: BoxFit.cover,
                          ),
                        )
                      ),
                )
              ).toList(),
            ),
    );
  }
}